package com.example.superoa.controller;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.superoa.model.service.AttendService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
@Controller
public class KqrepairController {
	@Autowired
	private AttendService a_biz;
	
	//kq-repair-assessor table初始化
	@RequestMapping("select_kqrepair")
	@ResponseBody
	public Map<String,Object> select_kqrepair(int page,int rows){
		Map<String,Object> map = new HashMap<>();
		//先分页
		Page<Object> pg = PageHelper.startPage(page, rows);
		JSONArray json = a_biz.selectRAll();
		int i=1;
		for (Object object : json) {
			JSONObject obj=(JSONObject) object;
			int shen=obj.getInteger("a_shen");
			String str="";
			if(shen==0) {
				str="未审核";
			}else if(shen==1) {
				str="通过";
			}else {
				str="未通过";
			}
				obj.put("sortable", i);
				obj.put("a_sta", str);
				i++;
			}
			//总记录
			map.put("total", pg.getTotal());
			//页内容
			map.put("rows", json);
			return map;
	}
	//kq-repair-assessor table初始化
		@RequestMapping("select_kqrepairDate")
		@ResponseBody
		public Map<String,Object> select_kqrepairDate(int page,int rows,Date kai,Date jie){
			Map<String,Object> map = new HashMap<>();
			//先分页
			Page<Object> pg = PageHelper.startPage(page, rows);
			JSONArray json = a_biz.selectRdate(kai, jie);
			int i=1;
			for (Object object : json) {
				JSONObject obj=(JSONObject) object;
				int shen=obj.getInteger("a_shen");
				String str="";
				if(shen==0) {
					str="未审核";
				}else if(shen==1) {
					str="通过";
				}else {
					str="未通过";
				}
					obj.put("sortable", i);
					obj.put("a_sta", str);
					i++;
				}
				//总记录
				map.put("total", pg.getTotal());
				//页内容
				map.put("rows", json);
				return map;
		}
}
